package com.dlwx.parttimetalent.views;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.NumberPicker;
import android.widget.TextView;

import com.dlwx.parttimetalent.R;
import com.dlwx.parttimetalent.inter.DialogInter;
import com.flyco.dialog.widget.base.BaseDialog;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/11/21.
 */

public class HouseAreaDialog extends BaseDialog {
    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    @BindView(R.id.tv_confirm)
    TextView tvConfirm;
    @BindView(R.id.np_house_area)
    MyNumberPicker npHouseArea;
    private Context context;
    private DialogInter inter;
    private String[] times;
    private int flag=0;

    public HouseAreaDialog(Context context, DialogInter inter,int flag) {
        super(context);
        this.context = context;
        this.inter = inter;
        this.flag=flag;
    }

    @Override
    public View onCreateView() {
        widthScale(0.85f);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_house_area, null);
        ButterKnife.bind(this, view);
//        initView();
        return view;
    }

    private void initView() {

    }

    @Override
    public void setUiBeforShow() {
        switch (flag){
            case 0:
                times = new String[]{"保密", "90平方以下", "90平方以上", "120平方以上", "180平方以上", "220平方以上"};
                break;
            case 1:
                times = new String[]{"暂未购房", "自购住房（无贷款）", "自购住房（有贷款）", "拥有多套房产", "与人合租", "独自租房", "父母同住"
                        , "住亲戚家", "住单位", "需要时购房"};
                break;
            case 2:
                times = new String[]{"保密", "2000-5000", "5000-8000", "8000-10000", "10000以上", "20000以上"};
                break;
            case 3:
                times = new String[]{"无", "经济型", "20万以上", "30万以上", "50万以上", "100万以上", "200万以上"};
                break;
        }
        npHouseArea.setDisplayedValues(times);
        npHouseArea.setMinValue(0);
        npHouseArea.setMaxValue(times.length - 1);
        npHouseArea.setValue(0);
        npHouseArea.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    }

    @OnClick({R.id.tv_cancel, R.id.tv_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_cancel:
                this.dismiss();
                break;
            case R.id.tv_confirm:
                inter.getInfo(times[npHouseArea.getValue()]);
                this.dismiss();
                break;
        }
    }
}
